﻿using ERPEF.Model;
using ERPIService;
using S4Project;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ERPService
{
    /// <summary>
    /// 销售订单从表
    /// </summary>
    public class sal_SalesOrder_cService : sal_SalesOrder_cIService
    {
        private readonly MyDbContext myDbContext;
        public sal_SalesOrder_cService(MyDbContext myDbContext)
        {
            this.myDbContext = myDbContext;
        }
        public Task<int> Add(sal_orders sal_Orders)
        {
            //myDbContext.Add("SET IDENTITY_INSERT dbo.bs_Model_From ON");
            //myDbContext.Add("SET IDENTITY_INSERT dbo.bs_Model_From   ON");
            myDbContext.sal_orders.Add(sal_Orders);
            return  myDbContext.SaveChangesAsync();
        }

        public async Task<int> Delete(int orders_id)
        {
            var del = myDbContext.sal_orders.Find(orders_id);
            if (del != null)
            {
                del.IsDeleted = true;
                await myDbContext.SaveChangesAsync();
                return 1;
            }
            return 0;
        }

        public Task<List<sal_orders>> Query()
        {
            throw new NotImplementedException();
        }

        public Task<int> UpdateModel(sal_orders sal_Orders)
        {
            myDbContext.sal_orders.Update(sal_Orders);
            return  myDbContext.SaveChangesAsync();
        }
    }
}
